<%= form_for_channel channel do |f| -%>
  <%= render 'edit_header', :f => f, :direction => Channel::Bidirectional -%>
  <%= render 'throttle', :f => f -%>
  <p>
  <%= f.label :max_unacknowledged_messages -%><br/>
  <%= f.text_field :max_unacknowledged_messages -%>
  </p>
  <p>
  <%= f.label :host -%><br/>
  <%= f.text_field :host -%>
  </p>
  <p>
  <%= f.label :port -%><br/>
  <%= f.text_field :port -%>
  </p>
  <p>
  <%= f.label :system_type -%><br/>
  <%= f.text_field :system_type -%>
  </p>
  <p>
  <%= f.label :source_ton -%><br/>
  <%= f.text_field :source_ton -%>
  </p>
  <p>
  <%= f.label :source_npi -%><br/>
  <%= f.text_field :source_npi -%>
  </p>
  <p>
  <%= f.label :destination_ton -%><br/>
  <%= f.text_field :destination_ton -%>
  </p>
  <p>
  <%= f.label :destination_npi -%><br/>
  <%= f.text_field :destination_npi -%>
  </p>
  <p>
  <%= f.label :user -%><br/>
  <%= f.text_field :user, :autocomplete => :off -%>
  </p>
  <p>
  <%= f.label :password -%><br/>
  <%= f.password_field :password, :autocomplete => :off -%>
  </p>
  <h5>Encoding</h5>
  <p>
  <%= f.check_box :endianness_mo, {:checked => channel.endianness_mo == 'little'}, :little, :big -%>
  <%= f.label 'Use little endian for ucs-2 MO messages' -%>
  </p>
  <p>
  <%= f.check_box :endianness_mt, {:checked => channel.endianness_mt == 'little'}, :little, :big -%>
  <%= f.label 'Use little endian for ucs-2 MT messages' -%>
  </p>
  <p>
  <%= f.check_box :accept_mo_hex_string -%>
  <%= f.label 'Hex strings' -%>
  </p>
  <%- encodings = [['ASCII', 'ascii'], ['Latin1', 'latin1'], ['UCS-2', 'ucs-2'], ['GSM 03.38', 'gsm']] -%>
  <p>
  <%= f.label 'Default MO encoding:' -%><br/>
  <%= f.select :default_mo_encoding, options_for_select(encodings, channel.default_mo_encoding) -%>
  </p>
  <p>
  <%= f.label 'MT encodings:' -%><br/>
  <%- channel.mt_encodings = encodings.map{|x|x[1]} unless channel.mt_encodings.present? -%>
  <%- encodings.each do |encoding| -%>
    <%- next if encoding[1] == 'gsm' -%>
    <input id="channel_configuration_mt_encodings" name="channel[mt_encodings][]" type="checkbox" value="<%= encoding[1] -%>" <%= 'checked="checked"' if channel.mt_encodings.include? encoding[1].to_s -%> /> <%= encoding[0] -%><br/>
  <%- end -%>
  </p>
  <p>
  <%= f.label 'MT max length:' -%><br/>
  <%= f.select :mt_max_length, options_for_select(['140', '160', '254'], channel.mt_max_length) -%>
  </p>
  <p>
  <%= f.label 'MT CSMS method:' -%><br/>
  <%= f.select :mt_csms_method, options_for_select([['UDH', 'udh'], ['Optional parameters', 'optional_parameters'], ['Message payload', 'message_payload']], channel.mt_csms_method) -%>
  </p>
  <h5>Vendor custom error codes</h5>
  <p>
    Enter here error codes known by your SMPP vendor that either must suspend the delivery of AO messages
    or reject them.
  </p>
  <p>
  <%= f.label :suspension_codes, 'Suspension codes (comma separated):' -%><br/>
  <%= f.text_field :suspension_codes -%>
  </p>
  <p>
  <%= f.label :rejection_codes, 'Rejection codes (comma separated):' -%><br/>
  <%= f.text_field :rejection_codes -%>
  </p>
  <%= render 'edit_footer', :f => f %>
<%- end -%>
